﻿using System.Configuration;
using Fjaspx.Common;
using System.Web;

namespace Fjaspx.Config
{
    /// <summary>
    /// 得到配置文件信息类 
    /// </summary>
    public class ROYcmsConfig
    {
        /// <summary>
        /// 得到配置文件信息方法  返回 Fjaspx.Sys.Model.ROYcmsConfig 
        /// </summary>
        /// <returns></returns>
        public static Fjaspx.Sys.Model.ROYcmsConfig Get_Config()
        {
            Fjaspx.Sys.Model.ROYcmsConfig CON = new Fjaspx.Sys.Model.ROYcmsConfig();
            //缓存处理
            if (DataCache.GetCache("_Config") == null)
            {
                CON.GUID = ConfigurationManager.AppSettings["GUID"].ToString();
                CON.UcenterWebserver = ConfigurationManager.AppSettings["UcenterWebserver"].ToString();
                CON.UcenterPassword = ConfigurationManager.AppSettings["UcenterPassword"].ToString();

                CON.web_host = ConfigurationManager.AppSettings["web_host"].ToString();
                CON.web_forge = ConfigurationManager.AppSettings["web_forge"].ToString();
                CON.web_name = ConfigurationManager.AppSettings["web_name"].ToString();
                CON.templet_language = ConfigurationManager.AppSettings["templet_language"].ToString();
                CON.templet_root = ConfigurationManager.AppSettings["templet_root"].ToString();
                CON.templet_file = ConfigurationManager.AppSettings["templet_file"].ToString();
                CON.HTML_zip = ConfigurationManager.AppSettings["HTML_zip"].ToString();
                CON.date_prefix = ConfigurationManager.AppSettings["date_prefix"].ToString();
                CON.FileManager_file_type = ConfigurationManager.AppSettings["FileManager_file_type"].ToString();
                CON.FileManager_root = ConfigurationManager.AppSettings["FileManager_root"].ToString();
                CON.password = ConfigurationManager.AppSettings["password"].ToString();
                CON.WEBSITE_UP_FILES = ConfigurationManager.AppSettings["WEBSITE_UP_FILES"].ToString();
                CON.HTML = ConfigurationManager.AppSettings["HTML"].ToString();

                CON.logo = ConfigurationManager.AppSettings["logo"].ToString();
                CON.title = ConfigurationManager.AppSettings["title"].ToString();
                CON.keyword = ConfigurationManager.AppSettings["keyword"].ToString();
                CON.Description = ConfigurationManager.AppSettings["Description"].ToString();
                CON.Copyright = ConfigurationManager.AppSettings["Copyright"].ToString();
                DataCache.SetCache("_Config", (object)CON);
            }
            else
            {
                CON = (Fjaspx.Sys.Model.ROYcmsConfig)DataCache.GetCache("_Config");
            }

            return CON;
        }
        public static string Get_Config(string Name)
        {
            Fjaspx.Sys.Model.ROYcmsConfig CON = new Fjaspx.Sys.Model.ROYcmsConfig();
            return ConfigurationManager.AppSettings[Name].ToString();
        }
        public static string GetCmsConfigValue(string name)
        {
            try
            {
                Fjaspx.Common.XmlControl XmlControl = new Fjaspx.Common.XmlControl(HttpContext.Current.Server.MapPath("~/CMS.CONFIG"));
                return XmlControl.GetText("Fjaspx/" + name);
            }
            catch
            {
                return "";
            }
        }

    }
}